package cn.biplam.front.component.view.systemManage.sysprivi.user.manage.navi;

import cn.biplam.common.ajxcode.SystemCode.TreeDcIndexCode;
import cn.biplam.common.ajxcode.SystemCode.UserManageNaviCode;
import cn.biplam.common.struc.SysStruc.UserIndexStruc;
import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.component.data.tree.treebase.TreeCallBackImg;
import cn.biplam.front.component.data.tree.treebase.TreeCallBackNew;
import cn.biplam.front.component.data.tree.treebase.TreeDcIndex;
import cn.biplam.front.component.data.tree.treebase.Tree_Type.Tree_NodeType_Commen;
import cn.biplam.front.component.data.tree.treebase.Tree_Type.Tree_PicType;
import cn.biplam.front.component.view.systemManage.sysprivi.user.UserManage;
import cn.biplam.front.component.view.tree.TreeBase;
import cn.biplam.front.component.view.tree.TreeView;

/**
 *  用户信息导航树
 * @author XiaoRuxing Nov 2, 20094:35:59 PM
 * @version 1.0
 */
public class UserNavi extends TreeView{

	public final static String cId=UserManageNaviCode.cId;
	/** 树展开动作ID */
	public static final String Expand = UserManageNaviCode.Navi;
	
	private final String User_Group_Img = "user_group.gif";
	private final String User_Img = "user.gif";
	
	public UserNavi() {
		super(Expand);
	}

	/**
	 * 传入树节点链接到的目标容器ID初始化
	 * @param targetId
	 */
	public void setTarget(String targetId) {
		this.targetId=targetId;
	}
	
	/**
	 * 设置树的数据信息
	 * @param treeBase			树的基础VC
	 * @param mUser				页面请求的用户类(由调用树的vc传入)
	 * @throws ErrorMessage
	 */
	@Override
	protected void setTree(TreeBase treeBase, UserInfo mUser)
			throws ErrorMessage {
		/**树的callback设置*/
		TreeCallBackNew callback = new TreeCallBackNew();
		//设置用户左键事件链接到显示用户信息
		callback.putLeftClick(Tree_NodeType_Commen.Leaf, UserManage.User_Base_Info, this.targetId);
		//设置用户主题左键事件链接到显示当前主题下所有下级
//		callback.putLeftClick(Tree_NodeType_Commen.RootTheme, UserManage.User_List, this.targetId);
//		callback.putLeftClick(Tree_NodeType_Commen.SubTheme, UserManage.User_List, this.targetId);
		
		//设置树DC
		treeBase.putTreeDc(1, 
				new TreeDcIndex(mUser,//用户信息
						UserIndexStruc.Table_Name,   //用户索引表名
						null,
						"3"),
				callback);
		//在根主题节点上设置右键
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.RootTheme, TreeDcIndexCode.Add_Theme, "创建用户组");
		//设置用户组节点右键
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.SubTheme,  TreeDcIndexCode.Add_Theme, "创建用户组");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.SubTheme,  TreeDcIndexCode.Edit, "修改");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.SubTheme,  TreeDcIndexCode.Del, 		"删除用户组");
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.SubTheme,  UserManage.User_Add, "创建用户");
		//设置用户节点右键
		treeBase.putRightMenuItem(1, Tree_NodeType_Commen.Leaf, UserManage.User_Del, "删除");
		//设置用户图片
		TreeCallBackImg img = TreeCallBackImg.getInstanct(Tree_PicType.Windows);
		img.setPicRootThemeHaveChild(User_Group_Img);
		img.setPicRootThemeNotHaveChild(User_Group_Img);
		img.setPicLeaf(User_Img);
		treeBase.setPic(1, img);
	}

	
}
